{{- $resource := 0 -}}
{{- $suffixList := site.Params.suffixValidationList | default (slice ".jpeg" ".jpg" ".png" ".gif" ".bmp" ".tif" ".tiff" ".webp" ".avif" ".svg") -}}

{{- $valid := false -}}
{{- if not (eq $suffixList false) -}}
    {{- $valid = (dict "Path" . "Suffixes" $suffixList | partial "function/suffixValidation.html") -}}
{{- end -}}

{{- if (eq $suffixList false) | or $valid -}}
    {{- with $remoteResource := resources.GetRemote . -}}
        {{- with .Err -}}
            {{- warnf "%s" . -}}
        {{ else }}
            {{- if eq $remoteResource.ResourceType "image" -}}
                {{- $resource = $remoteResource -}}
            {{- end -}}
        {{- end -}}
    {{- end -}}
{{- end -}}
{{- return $resource -}}
